#ifndef ATTRIBUTEWIDGET_H
#define ATTRIBUTEWIDGET_H

#include <QScrollArea>
#include "common.h"
#include "viewobject.h"

class QTableView;
class QTableWidget;
class QTableWidgetItem;
class QLineEdit;
class AttributeEdit;
class QListWidget;
class QListWidgetItem;
class StyleSetWidget;

const int attribute_num = 20;
#if 0
typedef struct AttributeItemInfo
{
   bool used;
   QTableWidgetItem *item;
   QTableWidgetItem *item_value;
   MyLineEdit       *value_widget;
}AttributeItem;
#else
typedef struct AttributeItemInfo
{
   bool used;
   QListWidgetItem *item;
   AttributeEdit *item_widget;
}AttributeItem;
#endif


class AttributeWidget : public QScrollArea
{
    Q_OBJECT
public:
    explicit AttributeWidget(QScrollArea *parent = nullptr);
    ~AttributeWidget();

    void slt_show_attribute(QString id, ViewObjectInfo *info);
    void slt_update_attribute(QString id, ViewObjectInfo *info);
    void delete_attribute(QString id);
    void cancel_attribute();
    void AddStyleWidget();

signals:
    void signal_update_graphics(QString);

private slots:
    void itemChanged(QString);
private:
#if 0
    QTableWidget *table_attribute;
#else
    QListWidget *list_attribute;
#endif
    AttributeItem attribute_item[attribute_num];

    void ParseAttribute(std::string json, bool exist = true);
    void generate_item(QString attribute, QString value);

    QString m_id = "";
    ViewObjectInfo *m_viewobjectinfo = NULL;

    StyleSetWidget *style_widget;
    QListWidgetItem *style_item;
};


#endif // ATTRIBUTEWIDGET_H
